package com.zero.dao.impl;

import com.zero.dao.IUserDao;
import com.zero.domain.User;
import com.zero.util.DBUtil;

import java.sql.ResultSet;
import java.sql.SQLException;

public class UserDaoImpl implements IUserDao {
    @Override
    public int findCount(User user) {
        ResultSet rs = DBUtil.executeQuery("select count(*) from user where username =? and userpwd =?",
                new String[]{user.getUsername(), user.getPassword()});
        int count = 0;
        try {
            if(rs.next()){
                count = rs.getInt(1);
            }

            DBUtil.close(rs);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return count;
    }
}
